package com.zh.zhbootauth.service.fallback;

import com.zh.zhbootauth.service.UserClient;
import com.zh.zhbootcommon.domain.DResult;
import com.zh.zhbootcommon.entity.user.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

/**
 * 描述: 服务降级
 *
 * @author: yanglin
 * @Date: 2021-10-29-21:08
 * @Version: 1.0
 */
@Slf4j
public class UserFallBackFactory implements FallbackFactory<UserClient> {

    @Override
    public UserClient create(Throwable throwable) {
        return new UserClient() {
            @Override
            public DResult<User> queryUserOne(int userId) {
                log.info("queryUserOne 服务降级");
                return DResult.of(User.builder().build());
            }

            @Override
            public DResult<User> queryUserInfo(User user) {
                log.info("queryUserInfo 服务降级");
                return DResult.of(User.builder().build());
            }
        };
    }
}
